package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkSpaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;

/*
 * 工作台相关代码
 * */
@RestController
@RequestMapping(value = "/admin/workspace")
@Slf4j
@Api(tags = "工作台相关接口")
public class WorkSpaceController {
    // 注入Service 层对象
    @Autowired
    private WorkSpaceService workSpaceService;

    /*工作台今日数据查询*/
    @GetMapping(value = "businessData")
    @ApiOperation(value = "今日数据统计")
    public Result<BusinessDataVO> businessData() {
        // 获得当天的开始与结束时间
        LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);

        // 调用service层接口
        BusinessDataVO businessDataVO = workSpaceService.getBusinessData(begin, end);
        return Result.success(businessDataVO);
    }

    /*查询订单管理数据功能*/
    @GetMapping(value = "overviewOrders")
    @ApiOperation(value = "查询订单管理功能方法")
    public Result<OrderOverViewVO> orderOverView() {
        return Result.success(workSpaceService.getOrderOverView());
    }

    /*查询菜品总览功能*/
    @GetMapping(value = "overviewDishes")
    @ApiOperation(value = "查询菜品总览功能方法")
    public Result<DishOverViewVO> dishOverView() {
        return Result.success(workSpaceService.getDishOverView());
    }

    /*查询套餐总览功能*/
    @GetMapping(value = "overviewSetmeals")
    @ApiOperation(value = "查询套餐总览功能")
    public Result<DishOverViewVO> setmealOverView() {
        return Result.success(workSpaceService.getSetmealOverView());
    }
}
